﻿using System;
using System.Linq;
using System.Web.UI.WebControls;
using Cotrobaie.UsersWebService;
using System.Drawing;
using WebChart;
using System.Collections.Generic;

namespace Cotrobaie
{
    public partial class Product : System.Web.UI.Page
    {
        protected override void OnInit(EventArgs e)
        {
            if (Request.QueryString["ProductID"] != null)
                PlaceHolder1.Attributes["src"] = "UserControl/DefaultStatistici.aspx?ProductID=" + Request.QueryString["ProductID"] + "&TextBoxMinDate=" + TextBoxMinDate.Text + "&TextBoxMaxDate=" + TextBoxMaxDate.Text;

            base.OnInit(e);
        }

        protected void Page_Load(object sender, EventArgs e)
        {

            ButtonStatistics.Attributes.Add("onMouseOut", "this.src='/images/statistics.png'");
            ButtonStatistics.Attributes.Add("onMouseOver", "this.src='/images/ostatistics.png'");
            ButtonDescr.Attributes.Add("onMouseOut", "this.src='/images/desc.png'");
            ButtonDescr.Attributes.Add("onMouseOver", "this.src='/images/odesc.png'");
            ButtonComments.Attributes.Add("onMouseOut", "this.src='/images/comm1.png'");
            ButtonComments.Attributes.Add("onMouseOver", "this.src='/images/ocomm1.png'");
            ButtonBasic.Attributes.Add("onMouseOut", "this.src='/images/basic.png'");
            ButtonBasic.Attributes.Add("onMouseOver", "this.src='/images/obasic.png'");

            String prodID = Server.UrlDecode(Request.Params["ProductID"]);
            long ProductID = 0;
            try { ProductID = long.Parse(prodID); }
            catch { Response.Redirect("~/Home.aspx"); }

            if (!Page.IsPostBack) Session["CommentsCurrPage"] = null;
            if (!Page.IsPostBack || sender == null) printInfo(ProductID);
        }
        private static double ProductBestPrice = Double.MaxValue;
        public void printInfo(long ProductID)
        {
            using (UsersSoapClient serviciu = new UsersSoapClient("UsersSoap"))
            {
                #region ok
                var res = serviciu.GetProdusByID(ProductID);
                if (res.Success)
                {
                    var produs = res.Produse.First();
                    pageTitle.InnerHtml = "<a id='HyperLinkBooks' href='Search.aspx?categoryID=" + produs.categ_id + "&Pg=0&IntrariPg=8' class= 'vmenulink' title='" + produs.categ_name + "'>" + produs.categ_name + "</a>" + " >> " + "<a id='HyperLinkProd' href='Product.aspx?ProductID=" + produs.ID.ToString() + "' class= 'vmenulink' title='" + produs.name + "'>" + produs.name + "</a>";
                    ImageProduct.ImageUrl = (produs.imageLarge != null && produs.imageLarge.Length > 0 ? produs.imageLarge : (produs.imageMedium != null && produs.imageMedium.Length > 0 ? produs.imageMedium : (produs.imageSmall != null && produs.imageSmall.Length > 0 ? produs.imageSmall : (produs.imageSwatch != null ? produs.imageSwatch : String.Empty))));
                    nameProd.InnerText = produs.name;
                    categoryProd.InnerText = produs.categ_name;
                    if (produs.NrAccesari != null) NoAccessed.Text = produs.NrAccesari.ToString() + " views";
                    else NoAccessed.Text = "First view!";
                    if (produs.authors != "")
                    {
                        author.Visible = true;
                        authorContent.InnerText = produs.authors;
                    }
                    if (produs.brand != "")
                    {
                        brand.Visible = true;
                        brandContent.InnerText = produs.brand;
                    }
                    var preturi = serviciu.GetProductPrice(ProductID);
                    if (preturi.Success)
                    {
                        var Prices = from i in (from p in preturi.Produse select p) group i by i.SiteID into h select h;
                        double? BestPrice = Double.MaxValue;
                        string BestProducer = " - ";
                        listPricesList.InnerHtml = String.Empty;
                        foreach (var p in Prices)
                        {
                            var ultim = p.OrderByDescending(x => x.Data).First();
                            if (ultim.Pret < BestPrice) { BestPrice = ultim.Pret; BestProducer = ultim.SiteName; }

                            listPricesList.InnerHtml += "$" + String.Format("{0:0,0.00}", ultim.Pret) + "&nbsp;-&nbsp;<a href='" + (ultim.SiteName.ToLower() == "amazon" ? produs.linkAmazon : (ultim.SiteName.ToLower() == "ebay" ? produs.linkEbay : produs.linkSite)) +
                                "' title='" + ultim.SiteName + "' class='blgrlink'>" + ultim.SiteName + "&nbsp;&nbsp;<img src='images/" + ultim.SiteName.ToLower() + ".jpg'></a>" + "<br/>";
                        }
                        if (BestPrice == Double.MaxValue) LiteralMinPrice.Text = "$ -";
                        LiteralMinPrice.Text = "$" + String.Format("{0:0,0.00}", BestPrice);
                        vendor.InnerHtml = "<a href='" + (BestProducer.ToLower() == "amazon" ? produs.linkAmazon : (BestProducer.ToLower() == "ebay" ? produs.linkEbay : produs.linkSite)) + "' title='" + BestProducer + "' class='blgrlink'>" + BestProducer + "&nbsp;&nbsp;<img src='images/" + BestProducer.ToLower() + ".jpg'></a>";

                        ProductBestPrice = (BestPrice != null ? (double)BestPrice : Double.MaxValue);//setez aici ca sa nu pot da pret mai mare decat asta la alarme
                    }

                    //partea 1


                    descriptionPDIV.InnerHtml = produs.description.Replace("&lt;", "<").Replace("&gt;", ">").Replace("&quot", "\"");
                    //partea 3
                    int COMENTARIIperPAGINA = 2;
                    {
                        if (Session["CommentsCurrPage"] == null) Session["CommentsCurrPage"] = 0;
                        var comentarii = serviciu.GetProductComments2(ProductID, (int)Session["CommentsCurrPage"] * COMENTARIIperPAGINA, COMENTARIIperPAGINA);

                        if (comentarii.Success)
                        {
                            if (comentarii.Commenturi.Count() == 0 && (int)Session["CommentsCurrPage"] == 0)
                            { commentsText.InnerText = "No comments added yet."; pagesComment.Visible = false; }
                            else
                            {
                                if (comentarii.Commenturi.Count() == 0 && (int)Session["CommentsCurrPage"] > 0)
                                {
                                    comentarii = serviciu.GetProductComments2(ProductID, ((int)Session["CommentsCurrPage"] - 1) * COMENTARIIperPAGINA, COMENTARIIperPAGINA);
                                    Session["CommentsCurrPage"] = (int)Session["CommentsCurrPage"] - 1;
                                    ButtonNextPage.Enabled = false;
                                    ButtonNextPage.CssClass = "button3";
                                    pagesComment.Visible = true;
                                }
                                if (comentarii.Commenturi.Count() < COMENTARIIperPAGINA) { ButtonNextPage.Enabled = false; ButtonNextPage.CssClass = "button3"; }
                                if ((int)Session["CommentsCurrPage"] == 0) { ButtonPrevPage.Enabled = false; ButtonPrevPage.CssClass = "button3"; }
                                LabelCurrentPage.Text = ((int)Session["CommentsCurrPage"] + 1).ToString();
                                pagesComment.Visible = true;
                                commentsText.InnerHtml = String.Empty;
                                foreach (var c in comentarii.Commenturi)
                                    commentsText.InnerHtml += "<div id='titleBarComment' class='titleBarComment'>" +
                                        "<span id='usernameComment' class='usernameComment'>&nbsp;" + c.user_name + "&nbsp;</span>-" +
                                        "<span id='titleComment' class='usernameComment'>&nbsp;&nbsp;" + c.titlu + "&nbsp;</span>-" +
                                        "<span id='dateComment' class='dateComment'>&nbsp;" + c.data.ToString("dd.MM.yyyy hh:mm") + "&nbsp;&nbsp;</span>" +
                                        "</div>" +
                                        "<div id='contentComment' class='contentComment'>" + (c.comment.Substring(0, c.comment.Length > 156 ? 156 : c.comment.Length)) + (c.comment.Length > 156 ? " ..." : String.Empty) + "</div>";
                            }
                        }
                    }
                }
                #endregion

                #region ok2
                var result = Session["UserID"] != null ? serviciu.GetUserBookmark((int)Session["UserID"], Session["UserUsername"].ToString(), Session["UserParola"].ToString(), ProductID) : null;
                if (result == null || result.Success == false)
                {
                    ImageButtonBookmark.ImageUrl = "images/bookmark.png";
                    ImageButtonBookmark.Attributes.Add("onMouseOver", "this.src='images/bookmarkred.png'");
                    ImageButtonBookmark.Attributes.Add("onMouseOut", "this.src='images/bookmark.png'");
                    ImageButtonBookmark.ToolTip = "Not in personal bookmarks";
                }
                else
                {
                    ImageButtonBookmark.ImageUrl = "images/bookmarkred.png";
                    ImageButtonBookmark.Attributes.Remove("onMouseOver");
                    ImageButtonBookmark.Attributes.Remove("onMouseOut");
                    ImageButtonBookmark.ToolTip = "In bookmarks";
                    ImageButtonBookmark.ImageUrl = "~/images/bookmarkdis.png";
                }

                var result2 = Session["UserID"] != null ? serviciu.GetUserAlarm((int)Session["UserID"], Session["UserUsername"].ToString(), Session["UserParola"].ToString(), ProductID) : null;
                if (result2 == null || result2.Success == false)
                {
                    ImageButtonAlert.ImageUrl = "images/alert.png";
                    ImageButtonAlert.Attributes.Add("onMouseOver", "this.src='images/alertred.png'");
                    ImageButtonAlert.Attributes.Add("onMouseOut", "this.src='images/alert.png'");
                    ImageButtonAlert.ToolTip = "Not in personal alerts";
                }
                else
                {
                    ImageButtonAlert.ImageUrl = "~/images/alertdis.png";
                    ImageButtonAlert.Attributes.Remove("onMouseOver");
                    ImageButtonAlert.Attributes.Remove("onMouseOut");
                    ImageButtonAlert.ToolTip = "In alerts";
                }

                var result3 = Session["UserID"] != null ? serviciu.GetUserRating((int)Session["UserID"], Session["UserUsername"].ToString(), Session["UserParola"].ToString(), ProductID) : null;
                if (result3 != null && result3.Success == true)
                {
                    ImageButton1.ImageUrl = ImageButton2.ImageUrl = ImageButton3.ImageUrl = ImageButton4.ImageUrl = ImageButton5.ImageUrl = "images/semptred.png";
                    switch (result3 != null && result3.rating != null ? (int)Math.Round((double)result3.rating, 0) : 0)
                    {
                        case 1: ImageButton1.ImageUrl = "images/sfullred.png"; break;
                        case 2: ImageButton1.ImageUrl = ImageButton2.ImageUrl = "images/sfullred.png"; break;
                        case 3: ImageButton1.ImageUrl = ImageButton2.ImageUrl = ImageButton3.ImageUrl = "images/sfullred.png"; break;
                        case 4: ImageButton1.ImageUrl = ImageButton2.ImageUrl = ImageButton3.ImageUrl = ImageButton4.ImageUrl = "images/sfullred.png"; break;
                        case 5: ImageButton1.ImageUrl = ImageButton2.ImageUrl = ImageButton3.ImageUrl = ImageButton4.ImageUrl = ImageButton5.ImageUrl = "images/sfullred.png"; break;
                        default: break;
                    }
                    ImageButton1.Attributes.Add("onMouseOver", "stars(this,'red')");
                    ImageButton2.Attributes.Add("onMouseOver", "stars(this,'red')");
                    ImageButton3.Attributes.Add("onMouseOver", "stars(this,'red')");
                    ImageButton4.Attributes.Add("onMouseOver", "stars(this,'red')");
                    ImageButton5.Attributes.Add("onMouseOver", "stars(this,'red')");
                    rating.Attributes.Add("onMouseOut", "unstars(this," + (result3 != null && result3.rating != null ? (int)Math.Round((double)result3.rating, 0) : 0) + ",'red')");
                    var result4 = serviciu.GetProductRating(ProductID);
                    scor.InnerText = (result4 != null && result4.rating != null ? String.Format("{0:0.00}", (double)result4.rating) : "0.00") + "/5 (" + result4.Mesaj.Replace(" ratinguri", "") + " vote" + (result4.Mesaj.Replace(" ratinguri", "").Trim() != "1" ? "s" : "") + ")";
                }
                else
                {
                    var result4 = serviciu.GetProductRating(ProductID);
                    if (result4.Success)
                    {
                        ImageButton1.ImageUrl = ImageButton2.ImageUrl = ImageButton3.ImageUrl = ImageButton4.ImageUrl = ImageButton5.ImageUrl = "images/sempt.png";
                        switch (result4 != null && result4.rating != null ? (int)Math.Round((double)result4.rating, 0) : 0)
                        {
                            case 1: ImageButton1.ImageUrl = "images/sfull.png"; break;
                            case 2: ImageButton1.ImageUrl = ImageButton2.ImageUrl = "images/sfull.png"; break;
                            case 3: ImageButton1.ImageUrl = ImageButton2.ImageUrl = ImageButton3.ImageUrl = "images/sfull.png"; break;
                            case 4: ImageButton1.ImageUrl = ImageButton2.ImageUrl = ImageButton3.ImageUrl = ImageButton4.ImageUrl = "images/sfull.png"; break;
                            case 5: ImageButton1.ImageUrl = ImageButton2.ImageUrl = ImageButton3.ImageUrl = ImageButton4.ImageUrl = ImageButton5.ImageUrl = "images/sfull.png"; break;
                            default: break;
                        }
                        ImageButton1.Attributes.Add("onMouseOver", "stars(this,'red')");
                        ImageButton2.Attributes.Add("onMouseOver", "stars(this,'red')");
                        ImageButton3.Attributes.Add("onMouseOver", "stars(this,'red')");
                        ImageButton4.Attributes.Add("onMouseOver", "stars(this,'red')");
                        ImageButton5.Attributes.Add("onMouseOver", "stars(this,'red')");
                        rating.Attributes.Add("onMouseOut", "unstars(this," + (result4 != null && result4.rating != null ? (int)Math.Round((double)result4.rating, 0) : 0) + ",'')");
                        scor.InnerText = (result4 != null && result4.rating != null ? String.Format("{0:0.00}", (double)result4.rating) : "0.00") + "/5 (" + result4.Mesaj.Replace(" ratinguri", "") + " votes)";
                    }
                }
                #endregion
            }
        }

        public void onAlertClick(object sender, EventArgs e)
        {
            if (Session["UserID"] == null) { Session["LastPageVisited"] = Request.RawUrl; Response.Redirect("Login.aspx"); }

            alertvis.Visible = !alertvis.Visible;

            using (UsersSoapClient serviciu = new UsersSoapClient("UsersSoap"))
            {
                var result = serviciu.GetUserPriceAlarm((int)Session["UserID"], Session["UserUsername"].ToString(), Session["UserParola"].ToString(), long.Parse(Server.UrlDecode(Request.Params["ProductID"])));
                if (result.Success)
                {
                    var alarma = result.Alarme.First();
                    TextBoxPret.Text = alarma.AlertPrice != null ? String.Format("{0:0,0.00}", alarma.AlertPrice) : String.Empty;
                    TextBoxProcent.Text = alarma.AlertProcent != null ? String.Format("{0:0,0.00}", alarma.AlertProcent) : String.Empty;
                }
            }
            Page_Load(null, null);
        }

        public void onBkmClick(object sender, EventArgs e)
        {
            if (Session["UserID"] == null) { Session["LastPageVisited"] = Request.RawUrl; Response.Redirect("Login.aspx"); }

            using (UsersSoapClient serviciu = new UsersSoapClient("UsersSoap"))
            {
                var result = serviciu.GetUserBookmark((int)Session["UserID"], Session["UserUsername"].ToString(), Session["UserParola"].ToString(), long.Parse(Server.UrlDecode(Request.Params["ProductID"])));
                if (!result.Success && result.Mesaj == "Bookmark inexistent")
                {
                    var result2 = serviciu.AddBookmark((int)Session["UserID"], Session["UserUsername"].ToString(), Session["UserParola"].ToString(), long.Parse(Server.UrlDecode(Request.Params["ProductID"])));
                    if (!result2.Success) { }
                }
                else if (result.Success)
                {
                    var result2 = serviciu.RemoveUserBookmark((int)Session["UserID"], Session["UserUsername"].ToString(), Session["UserParola"].ToString(), long.Parse(Server.UrlDecode(Request.Params["ProductID"])));
                    if (!result2.Success) { }
                }
                else { }
            }

            Page_Load(null, null);
        }

        public void ratingClick(object sender, EventArgs e)
        {
            if (Session["UserID"] == null) { Session["LastPageVisited"] = Request.RawUrl; Response.Redirect("Login.aspx"); }

            int newRating = 0;
            switch (((ImageButton)sender).ID)
            { case "ImageButton1":newRating = 1; break; case "ImageButton2":newRating = 2; break; case "ImageButton3":newRating = 3; break; case "ImageButton4":newRating = 4; break; case "ImageButton5":newRating = 5; break; }
            using (UsersSoapClient serviciu = new UsersSoapClient("UsersSoap"))
            {
                var result = serviciu.AddRating((int)Session["UserID"], Session["UserUsername"].ToString(), Session["UserParola"].ToString(), long.Parse(Server.UrlDecode(Request.Params["ProductID"])), newRating);
                if (!result.Success) { }
            }

            Page_Load(null, null);
        }

        public void tabClick(object sender, EventArgs e)
        {
            ImageButton but = (ImageButton)sender;

            if (but.ID == "ButtonDescr")
            {
                det.Visible = false;
                descriptionP.Visible = true;
                comments.Visible = false;
                statistics.Visible = false;
            }

            else if (but.ID == "ButtonComments")
            {
                det.Visible = false;
                comments.Visible = true;
                descriptionP.Visible = false;
                statistics.Visible = false;
            }

            else if (but.ID == "ButtonStatistics")
            {
                det.Visible = false;
                statistics.Visible = true;
                descriptionP.Visible = false;
                comments.Visible = false;
            }

            else
            {
                det.Visible = true;
                statistics.Visible = false;
                descriptionP.Visible = false;
                comments.Visible = false;
            }

        }
        public void onClickAddComment(object sender, EventArgs e)
        {
            if (Session["UserID"] == null) { Session["LastPageVisited"] = Request.RawUrl; Response.Redirect("Login.aspx"); }

            addComment.Visible = true;
            ButtonAddComment.Visible = false;
        }

        public void onClickSendComment(object sender, EventArgs e)
        {
            using (UsersSoapClient serviciu = new UsersSoapClient("UsersSoap"))
            {
                var result = serviciu.AddComment((int)Session["UserID"], Session["UserUsername"].ToString(), Session["UserParola"].ToString(), long.Parse(Server.UrlDecode(Request.Params["ProductID"])), TextBoxNewComment.Text, TextBoxTitleComment.Text);
                if (!result.Success) { }
                else
                {
                    addComment.Visible = false;
                    ButtonAddComment.Visible = true;
                    TextBoxNewComment.Text = TextBoxTitleComment.Text = String.Empty;
                    Page_Load(null, null);
                }
            }
        }

        protected void ButtonPrevPage_Click(object sender, EventArgs e)
        {
            if (Session["CommentsCurrPage"] != null)
                Session["CommentsCurrPage"] = (int)Session["CommentsCurrPage"] - 1;
            else Session["CommentsCurrPage"] = 0;
            ButtonNextPage.Enabled = true;
            ButtonNextPage.CssClass = "button2";
            Page_Load(null, null);
        }

        protected void ButtonNextPage_Click(object sender, EventArgs e)
        {
            if (Session["CommentsCurrPage"] != null)
                Session["CommentsCurrPage"] = (int)Session["CommentsCurrPage"] + 1;
            else Session["CommentsCurrPage"] = 1;
            ButtonPrevPage.Enabled = true;
            ButtonPrevPage.CssClass = "button2";
            Page_Load(null, null);
        }

        protected void ButtonOk_Click(object sender, EventArgs e)
        {
            if (TextBoxPret.Text != String.Empty)
                try
                {
                    double pret;
                    if (!double.TryParse(TextBoxPret.Text, out pret)) { ImageButtonProcAlarm.ImageUrl = "~/images/okred.png"; return; }
                    if (pret <= 0 || ProductBestPrice <= pret) { ImageButtonProcAlarm.ImageUrl = "~/images/okred.png"; return; }
                    using (UsersSoapClient serviciu = new UsersSoapClient("UsersSoap"))
                    {
                        var result = serviciu.AddAlarmPrice((int)Session["UserID"], Session["UserUsername"].ToString(), Session["UserParola"].ToString(), long.Parse(Server.UrlDecode(Request.Params["ProductID"])), pret);
                        if (!result.Success) { ImageButtonProcAlarm.ImageUrl = "~/images/okred.png"; return; }
                    }
                    ImageButtonProcAlarm.ImageUrl = "~/images/okgr.png";
                }
                catch { }
            else using (UsersSoapClient serviciu = new UsersSoapClient("UsersSoap"))
                {
                    var result = serviciu.AddAlarmPrice((int)Session["UserID"], Session["UserUsername"].ToString(), Session["UserParola"].ToString(), long.Parse(Server.UrlDecode(Request.Params["ProductID"])), -1);
                    if (!result.Success) { ImageButtonProcAlarm.ImageUrl = "~/images/okred.png"; return; }
                    ImageButtonProcAlarm.ImageUrl = "~/images/ok.png";
                }
            if (TextBoxProcent.Text != String.Empty)
                try
                {
                    double pret;
                    if (!double.TryParse(TextBoxProcent.Text, out pret)) { ImageButtonPriceAlarm.ImageUrl = "~/images/okred.png"; return; }
                    if (pret <= 0 || pret >= 100) { ImageButtonPriceAlarm.ImageUrl = "~/images/okred.png"; return; }
                    using (UsersSoapClient serviciu = new UsersSoapClient("UsersSoap"))
                    {
                        var result = serviciu.AddAlarmProcent((int)Session["UserID"], Session["UserUsername"].ToString(), Session["UserParola"].ToString(), long.Parse(Server.UrlDecode(Request.Params["ProductID"])), pret);
                        if (!result.Success) { ImageButtonPriceAlarm.ImageUrl = "~/images/okred.png"; return; }
                    }
                    ImageButtonPriceAlarm.ImageUrl = "~/images/okgr.png";
                }
                catch { }
            else using (UsersSoapClient serviciu = new UsersSoapClient("UsersSoap"))
                {
                    var result = serviciu.AddAlarmProcent((int)Session["UserID"], Session["UserUsername"].ToString(), Session["UserParola"].ToString(), long.Parse(Server.UrlDecode(Request.Params["ProductID"])), -1);
                    if (!result.Success) { ImageButtonPriceAlarm.ImageUrl = "~/images/okred.png"; return; }
                    ImageButtonPriceAlarm.ImageUrl = "~/images/ok.png";
                }
            if (TextBoxPret.Text == String.Empty && TextBoxProcent.Text == String.Empty)
            {
                using (UsersSoapClient serviciu = new UsersSoapClient("UsersSoap"))
                {
                    var result = serviciu.RemoveUserAlarm((int)Session["UserID"], Session["UserUsername"].ToString(), Session["UserParola"].ToString(), long.Parse(Server.UrlDecode(Request.Params["ProductID"])));
                    if (!result.Success) { ImageButtonPriceAlarm.ImageUrl = ImageButtonProcAlarm.ImageUrl = "~/images/okred.png"; return; }
                }
                ImageButtonAlert.ImageUrl = "images/alert.png";
                ImageButtonAlert.Attributes.Add("onMouseOver", "this.src='images/alertred.png'");
                ImageButtonAlert.Attributes.Add("onMouseOut", "this.src='images/alert.png'");
                ImageButtonAlert.ToolTip = "Not in personal alerts";
            }
            else
            {
                ImageButtonAlert.ImageUrl = "~/images/alertdis.png";
                ImageButtonAlert.Attributes.Remove("onMouseOver");
                ImageButtonAlert.Attributes.Remove("onMouseOut");
                ImageButtonAlert.ToolTip = "In alerts";
            }
        }
        protected void ButtonGrafic_Click(object sender, EventArgs e)
        {
            if (Request.QueryString["ProductID"] != null)
                PlaceHolder1.Attributes["src"] = "UserControl/DefaultStatistici.aspx?ProductID=" + Request.QueryString["ProductID"] + "&TextBoxMinDate=" + TextBoxMinDate.Text + "&TextBoxMaxDate=" + TextBoxMaxDate.Text + "&Check=" + CheckBoxTrend.Checked;
            Session["ButtonPressed"] = true;
        }

        protected void CheckBoxChanged(object sender, EventArgs e)
        {
            PlaceHolder1.Attributes["src"] = "UserControl/DefaultStatistici.aspx?ProductID=" + Request.QueryString["ProductID"] + "&TextBoxMinDate=" + TextBoxMinDate.Text + "&TextBoxMaxDate=" + TextBoxMaxDate.Text + "&Check=" + CheckBoxTrend.Checked;
            Session["CheckBoxChecked"] = true;
        }

        protected void goHome(object sender, EventArgs e)
        {
            Response.Redirect("~/Home.aspx");
        }
    }    
}